
showInitialInformationOnPage();


function showInitialInformationOnPage() {
    // Показываем начальную информацию на странице

    if (document.location.pathname != '/') return;
    displayListOfPeople();
};


function displayListOfPeople() {
    // Отображаем список людей

    let url = document.location.origin + '/people/';
    url = new URL(url);
    url.searchParams.set('get_list_of_all_people', 'true');

    base.sendAjaxRequest('GET', url)
        .then(result => {
            insertPeople(result);
        })


    // НИЖЕ ОПРЕДЕЛЕНИЕ ФУНКЦИЙ

    function insertPeople(listOfPeople) {
        listOfPeople = Object.values(listOfPeople);
        base.clearListOfPeople();

        for (const people of listOfPeople) {
            const htmlToDisplayPerson = base.getHtmlToDisplayPerson(people);
            document.querySelector('.list-of-people .content-list-of-people').insertAdjacentHTML('beforeend', htmlToDisplayPerson)
        }
    }
};